Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adhese: Switch to openrtb2 endpoint #3864

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mefjush
Copy link
Contributor

@mefjush mefjush commented Aug 16, 2024

Switch the Adhese adapter from /json to /openrtb2 endpoint. This is to keep our go adapter in line with with prebid-server-java Adhese adapter.

if err != nil {
return nil, []error{err, WrapServerError(fmt.Sprintf("Could not parse Price %v as float ", string(adheseBid.Extension.Prebid.Cpm.Amount)))}
func inferBidTypeFromImp(i openrtb2.Imp) (openrtb_ext.BidType, []error) {
if i.Banner != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeBanner, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mefjush any feedback on this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've opened a PR where we document it as a limitation that multiple formats aren't supported.
https://github.com/prebid/prebid.github.io/pull/5618/files

height, err := strconv.ParseInt(adheseBid.Height, 10, 64)
if err != nil {
return nil, []error{err, WrapServerError(fmt.Sprintf("Could not parse Height %v as int ", string(adheseBid.Height)))}
if i.Native != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeNative, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've documented this limitation in https://github.com/prebid/prebid.github.io/pull/5618/files.

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, f031874

adhese

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:25:	makeSlot		100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:29:	MakeRequests		85.7%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:106:	inferBidTypeFromImp	100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:123:	MakeBids		72.7%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:199:	Builder			100.0%
total:									(statements)		82.9%

@skonky
Copy link

skonky commented Aug 19, 2024

@SyntaxNode It got delayed a bit because of some internal testing with the new adapter, the techlead from Adhese has re-opened the PR.

Sorry for the late reply!

Comment on lines 21 to 22
type ExtTargetsAdhese map[string][]string
type ExtImpAdheseWrapper map[string]ExtTargetsAdhese
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtTargetsAdhese ExtImpAdheseWrapper type are accessible outside package adhese

scope of these types should be within package adhese

type extTargetsAdhese map[string][]string
type extImpAdheseWrapper map[string]ExtTargetsAdhese

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@@ -1,4 +1,4 @@
endpoint: "https://ads-{{.AccountID}}.adhese.com/json"
endpoint: "https://ads-{{.AccountID}}.adhese.com/openrtb2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mefjush endpoint is not reachable

curl -i --location --request POST 'https://ads-1.adhese.com/openrtb2'
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

Copy link
Contributor Author

@mefjush mefjush Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to the other concern you already shared. We require the users of the adapter to specify the AccountID so it matches their account name in Adhese. An example endpoint that could be reached is https://ads-demo.adhese.com/openrtb2 - that's coupled with demo account in our system.

Can we do any better to make this requirement more obvious to the user?

Account string `json:"account"`
Location string `json:"location"`
Format string `json:"format"`
Targets map[string][]string `json:"targets,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mefjush should update bidder docs to add description for Targets ext param

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field is called data for pbjs, but it got renamed to targets in both the server-side adapters. I've added a column in the documentation where we specify the pbs ext name next to the pbjs configuration param name.
https://github.com/prebid/prebid.github.io/pull/5618/files

Comment on lines +33 to +40
[]*adapters.RequestData,
[]error,
) {
if len(request.Imp) == 0 {
return nil, []error{&errortypes.BadInput{
Message: "No impression in the bid request",
}}
}
imp := &request.Imp[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mefjush based on changes it appears that only first imp from request is considered by adapter. Should update bidder docs to explicitly specify this behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 125 to 142
if responseData.StatusCode == http.StatusNoContent {
return nil, nil
}

if responseData.StatusCode == http.StatusBadRequest {
err := &errortypes.BadInput{
Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.",
}
return nil, []error{err}
}
return bidderResponse, errs
}

func convertAdheseBid(adheseBid AdheseBid, adheseExt AdheseExt, adheseOriginData AdheseOriginData) openrtb2.BidResponse {
adheseExtJson, err := json.Marshal(adheseOriginData)
if err != nil {
adheseExtJson = make([]byte, 0)
if responseData.StatusCode != http.StatusOK {
err := &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode),
}
return nil, []error{err}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could make use of response util here

package adapters
import (
"fmt"
"net/http"
"github.com/prebid/prebid-server/v2/errortypes"
)
func CheckResponseStatusCodeForErrors(response *ResponseData) error {
if response.StatusCode == http.StatusBadRequest {
return &errortypes.BadInput{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}
}
if response.StatusCode != http.StatusOK {
return &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode),
}
}
return nil
}
func IsResponseStatusCodeNoContent(response *ResponseData) bool {
return response.StatusCode == http.StatusNoContent
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

}
// create a new bidResponse with a capacity of 1 because we only expect 1 bid
bidResponse := adapters.NewBidderResponseWithBidsCapacity(1)
bidResponse.Currency = response.Cur
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapters.NewBidderResponseWithBidsCapacity initialises bidResponse.Currency with USD value

consider scenario where bidResponse.Currency is empty, assigning response.Cur directly may set bidResponse.Currency to empty value

consider implementing following changes:


	bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(response.SeatBid[0].Bid))

        if response.Cur != "" {

	 bidResponse.Currency = response.Cur

       }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@@ -1,4 +1,4 @@
endpoint: "https://ads-{{.AccountID}}.adhese.com/json"
endpoint: "https://ads-{{.AccountID}}.adhese.com/openrtb2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider that usage of partial dynamic urls is being discouraged and prebid team in future will be working to avoid usage of dynamic subdomain in endpoint url.
Major concerns with such usage are,

  • security concerns
    The security aspect is alleviated by using a fixed top level domain. Due to the potential harm to hosts, we are strict in this requirement. We are working towards fixing the few adapters currently in violation.
  • connection performance
    The connection performance advice is for your benefit. Client specific subdomains prevent Prebid Server from reusing connections across your clients which results in more connections needed for your adapter. The issue gets worse the more successful you are in attracting new clients. Hosts may choose to disable your adapter due to this behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we address this concern separately from this PR?

Historically we've been always assigning individual domains to each tenant in out system, eg. ads-demo.adhese.com for demo account.

To change this approach we'd need to introduce a few architectural changes to our services. I'm happy to plan them in, but we'd rather move forward with the new adapter before the new endpoint approach is implemented.

@bsardo bsardo changed the title Adhese: Switch the adapter to /openrtb2 endpoint Adhese: Switch to /openrtb2 endpoint Sep 3, 2024
@bsardo bsardo changed the title Adhese: Switch to /openrtb2 endpoint Adhese: Switch to openrtb2 endpoint Sep 3, 2024
Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, b2c13e2

adhese

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:24:	makeSlot		100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:28:	MakeRequests		85.7%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:105:	inferBidTypeFromImp	100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:122:	MakeBids		78.1%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:191:	Builder			100.0%
total:									(statements)		85.3%

Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 0e97d54

adhese

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:24:	makeSlot		100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:28:	MakeRequests		85.7%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:105:	inferBidTypeFromImp	100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:122:	MakeBids		78.1%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:191:	Builder			100.0%
total:									(statements)		85.3%

mefjush and others added 7 commits September 17, 2024 14:31
* change endpoint

* initial setup rewrite to POST endpoint

* modify MakeBids and MakeRequests

* change the name from Keywords to Targets so it matches json

* tests

---------

Co-authored-by: skonky <[email protected]>
Co-authored-by: frank <[email protected]>
Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 8f5225f

adhese

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:24:	makeSlot		100.0%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:28:	MakeRequests		85.7%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:105:	inferBidTypeFromImp	92.9%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:133:	MakeBids		78.1%
github.com/prebid/prebid-server/v2/adapters/adhese/adhese.go:202:	Builder			100.0%
total:									(statements)		85.0%

@mefjush
Copy link
Contributor Author

mefjush commented Sep 24, 2024

Hi @onkarvhanumante I think we've addressed (or replied to) all the comments in the PR. Could we have another round of review please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants